package com.example.expandableview;
import com.expandable.view.HmCheckbox;
import ohos.agp.components.*;
import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.Color;
import ohos.app.Context;

import java.math.BigDecimal;

public class ExpandedListItemView extends DependentLayout {

    private DependentLayout mRoot;

    private Text mText;

    private HmCheckbox mCheckbox;


    public ExpandedListItemView(Context context) {
        super(context);
        init();
    }

    private void init() {
        LayoutScatter.getInstance(this.mContext).parse(ResourceTable.Layout_expandable_list_item_view, this, true);
        mRoot = (DependentLayout) findComponentById(ResourceTable.Id_expandable_list_item_view_root);
        mText = (Text) findComponentById(ResourceTable.Id_expandable_list_item_view_text);
        mCheckbox = (HmCheckbox) findComponentById(ResourceTable.Id_expandable_list_item_view_checkbox);
        this.mRoot.setClickedListener(new ClickedListener() {
            @Override
            public void onClick(Component component) {
                mCheckbox.setChecked(!mCheckbox.isChecked());
            }
        });
    }

    public void setText(String text, boolean showCheckbox) {
        this.mText.setText(text);
        System.out.println("showCheckbox------" + showCheckbox);
        if (!showCheckbox) {
            this.mCheckbox.setVisibility(Component.HIDE);
        }
    }

}
